package com.sunzm.dynamic_rule.functions;

import com.alibaba.fastjson.JSON;
import com.sunzm.dynamic_rule.pojo.LogBean;
import org.apache.commons.lang3.StringUtils;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.util.Collector;

/**
 * JSON字符串转换成LogBean对象的flatMap函数封装
 *
 * @author Administrator
 * @version 1.0
 * @date 2021-07-07 1:01
 */
public class Json2LogBeanFlatMapFunction implements FlatMapFunction<String, LogBean> {
    @Override
    public void flatMap(String value, Collector<LogBean> out) throws Exception {
        if(StringUtils.isNotBlank(value)){
            out.collect(JSON.parseObject(value,LogBean.class));
        }
    }
}
